package com.chunuo.mvc.dao;

import com.chunuo.configuration.annotation.*;
import com.chunuo.configuration.interfaces.DataVisit;
import com.chunuo.mvc.entity.SysUser;

import java.util.List;

/**
 * DAO
 *
 * @author liujiamiao
 * @email 2544296058@qq.com
 * @date 2020-12-22 13:29
 */
//@Component
public interface UserDao extends DataVisit<SysUser> {

    @SelectForeach("select * from sys_user")
    List<SysUser> findSysUserList();

    @SelectOne("select * from sys_user where id = ?")
    SysUser findSysUserById(String id);

    @Single("select user_name from sys_user where id = ?")
    String findUserNameById(String id);

    @Update("update sys_user set user_name = #{username} , realname = #{realname} where id = #{id}")
    int update(SysUser sysUser);

    @Update("delete from sys_user where id = #{id}  <if test=username==null> and 1 = 1</if><else> and user_name = #{username} </else>")
    int deleteSysUserByUsername(@Param("id") String id,@Param("username") String username);

}
